package com.xuetang9.t9.hotel.services.impl;

import com.xuetang9.t9.hotel.beans.EFood;
import com.xuetang9.t9.hotel.mapper.EFoodMapper;
import com.xuetang9.t9.hotel.mapper.condition.impl.FoodCondition;
import com.xuetang9.t9.hotel.services.IFoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName FoodService
 * @Description TODO
 * @Author qin
 * @Date 2020/2/24 15:14
 * @Version 1.0
 **/
@Service
public class FoodService implements IFoodService {
    @Autowired
    private EFoodMapper foodMapper;


    @Override
    public List<EFood> queryByCategoryId(long categoryId) {
        return foodMapper.queryByCategoryId(categoryId);
    }

    @Override
    public List<EFood> queryAll() {
        return foodMapper.queryAll();
    }

    @Override
    public List<EFood> foodList(int nowPage, int size) {
        int begin = (nowPage-1)*size;
        return foodMapper.queryFoodList(begin,size);
    }

    @Override
    public boolean insertFood(EFood food) {
        return foodMapper.insertFood(food.getName(),food.getFoodDescribe(),food.getPrice(),food.getCostPrice(),food.getCategory(),food.getInventoryCount(),food.getPicPath(),food.getLen())>0;
    }

    @Override
    public boolean deleteFood(int id) {
        return foodMapper.deleteFood(id)>0;
    }

    @Override
    public boolean updateFood(EFood food) {
        return foodMapper.updateFood(food.getName(),food.getFoodDescribe(),food.getPrice(),food.getCostPrice(),food.getCategory(),food.getInventoryCount(),food.getPicPath(),food.getLen(),food.getId())>0;
    }

    @Override
    public int countFood() {
        return foodMapper.queryFoodCount();
    }

    @Override
    public List<EFood> queryByAll(FoodCondition condition) {
        return foodMapper.selectByClear(condition);
    }

    @Override
    public boolean updateByClean(FoodCondition condition) {
        return foodMapper.updateByClean(condition) > 0;
    }

    @Override
    public Long selectByCount(FoodCondition condition) {
        return foodMapper.selectByCount(condition);
    }

    @Override
    public List<EFood> analysisFood() {
        return foodMapper.queryFoodAnalysis();
    }

    @Override
    public EFood one(Integer id) {
        return foodMapper.queryById(id);
    }

    @Override
    public List<Integer> queryFoodOrder() {
        return foodMapper.queryFoodOrder();
    }

    @Override
    public List<String> queryFoodName() {
        return foodMapper.queryFoodName();
    }
}
